var PRIMARY_PATH3 = "";
var BASE_PATH33 = "";

function setPath(path,basePath){
	PRIMARY_PATH3 = path;
	BASE_PATH3 = basePath;
}

$(function() {
	showTypeContent('largeAmountTransaction','largeAmountTransaction','交易所大宗交易指令');
	WASP_WIDGET.triggerDateStyleWithYMD($(".directiveStime"));
	WASP_WIDGET.triggerDateStyleWithYMD($(".directiveEtime"));
});

function doSubmit(id){
	ctools.confirm({text:"是否确认提交下单？"},function(isConfirm){
		if(isConfirm){
			var data = $('#'+id).serializeArray();
			if (data == null || !data) {
						return;
			}
			var actionUrl= PRIMARY_PATH3 + "insertTradeOrder.do";
			$.ajax({
				type: 'POST',
				url: actionUrl,
				dataType:'json',
				data:data,
				success: function(data){
					data = JSON.parse(data);
					if(data.resultCode == "0000"){
						ctools.alert_sweet('交易下单成功！', "success", "" , function(){
							$(".resetForm").click();
							$(".nav-tabs1 li").eq(0).find("a").click();
						});
					}else{
						ctools.alert_sweet('交易下单失败！', "error", "失败原因："+data.resultMsg);
					}
				},
				error:function(xhr){
					switch(xhr.status){
						case 403:sweetAlert("对不起，您无此权限！","","error");break;
						case 404:sweetAlert("对不起，无此页面！", "","error");break;
						case 500:sweetAlert("内部错误，请联系管理员！","","error");break;  
						case 504:sweetAlert("超时，请联系管理员！", "","error");break;  
						case 417:sweetAlert("内部错误，请联系管理员！", "","error");break;  
					}
				}
			});
		}
	});
}

function showTypeContent(id,type,name){
	$(".directiveStime,.directiveEtime").val($("#nowDate").val());
	$(".page-body1").hide();
	$("#"+id).show();
	$("#"+id +" select").select2();
	$("#"+id +" h3").html(name);
	$("input[name='directiveType']").val("");
	$("#"+id +" input[name='directiveType']").val(type);
	//初始化产品下拉框
    WASP_WIDGET.triggerPrdInfoSelect("prjCode1");
    WASP_WIDGET.triggerPrdInfoSelect("prjCode2");
    WASP_WIDGET.triggerPrdInfoSelect("prjCode3");
}